<?php
if(empty($buid))
	msg($config['weburl']."/login.php","请登录");

include_once("$config[webroot]/module/product/includes/plugin_cart_class.php");
$cart=new cart();
$_GET['id']*=1;
$_GET['nums']*=1;
$_GET['deid']*=1;
$_GET['cgnum']*=1;

//---------------------清空购物车
if(!empty($_GET['clear']))
{
	$cart->clear_cart();
	msg($config['weburl']."/?m=product","购物车已经清空");
}

if(!empty($_GET['cgnum'])&&!empty($_GET['id']))
{  
	$flag=$cart->edit_cart($_GET['id'],$_GET['cgnum']);
	if($flag=='error')
		msg($config['weburl']."/?m=product&s=cart","库存数量不够");
}
//-----------------------向购物车添加商品信息
if(!empty($_GET['id'])&&!empty($_GET['nums']))
{
	$flag=$cart->add_cart($_GET['id'],$_GET['nums']); 
	if($flag=='error')
		msg($config['weburl']."/?m=product&s=cart","商品不存在");
	if($flag=='error1')
		msg($config['weburl']."/?m=product&s=cart","库存数量不够");
}
//-------------------------删除商品信息
if(!empty($_GET['deid'])&&!empty($buid))
{ 
	$cart->del_cart($_GET['deid']);
}
//--------------------------读出购物车的数据
if(!empty($buid))
{
	$re=$cart->get_listcart();
	$tpl->assign("cart",$re);
} 
//================================================
$tpl->assign("current","product");
include_once("footer.php");
$out=tplfetch("cart.htm",$flag,true);
?>